<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <el-form-item label="运单号" prop="waybillNum">
        <el-input
          v-model="queryParams.waybillNum"
          placeholder="请输入运单号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--<el-form-item label="出场时间">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>-->
      <el-form-item label="车牌号" prop="carNo">
        <el-input
          v-model="queryParams.carNo"
          placeholder="请输入车牌号码或者挂车号码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所属场站" prop="stationName">
        <el-input
          v-model="queryParams.stationName"
          placeholder="请输入所属场站"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--<el-form-item label="驾驶员" prop="driverName">
        <el-input
          v-model="queryParams.driverName"
          placeholder="请输入驾驶员姓名或联系电话"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!--<el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['data:waybill:export']"
        >导出</el-button>
      </el-col>
    </el-row>-->

    <el-table v-loading="loading" :data="czycList" :max-height="tableHeight" @selection-change="handleSelectionChange">
      <el-table-column label="场站名称" align="center" prop="stationName" />
      <el-table-column label="运单编号" align="center" prop="waybillNum" />
      <el-table-column label="车牌号码" align="center" prop="carNo" />
      <el-table-column label="驾驶员" align="center" prop="recipientPeople" />
      <el-table-column label="联系电话" align="center" prop="recipientPhone" />
      <el-table-column label="运单发起时间" align="center" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.waybillCreateTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="发起人" align="center" prop="fzName" />
      <el-table-column label="异常原因" align="center" prop="abnormalDesc" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
          >称重详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
  import { listGetRecordData } from "@/api/weight/abnormal";

  export default {
    name: "noRecordabnormal",
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 总条数
        total: 0,
        // 称重异常
        czycList: [],
        // 认证状态
        dict_waybill_status: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        tableHeight: window.innerHeight - 275,
        //日期范围
        dateRange: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          waybillNum: undefined,
          stationName: undefined,
          carNo: undefined,
          isAbnormal: undefined
        },
        // 表单参数
        form: {}
      };
    },
    created() {
      this.getList();
      // 认证状态
      this.getDicts("waybill_status").then(response => {
        this.dict_waybill_status = response.data;
      });
    },
    methods: {
      /** 查询运单列表 */
      getList() {
        this.loading = true;
        listGetRecordData(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.czycList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },

      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          waybillId: undefined,
          waybillNum: undefined,
          stationName: undefined,
          carNo: undefined,
          driverName: undefined,
          isAbnormal: undefined
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      /** 详情按钮操作 */
      handleView(row) {
        this.reset();
        const id = row.waybillId
        this.$router.push({
          path:"/weigh/waybilldetail",
          query:{
            id:id
          }
        })

        // getWaybill(waybillId).then(response => {
        //   this.form = response.data;
        //   this.open = true;
        //   this.title = "运单详情";
        // });
      },
      //table改变按钮
      handleSelectionChange(){

      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const id = row.waybillId;
        console.info(id)
        this.$confirm('是否确认删除运单数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delWaybill(id);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有运单数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportWaybill(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
      }
    }
  };
</script>
